<?php
/**
 * Created by PhpStorm.
 * User: wumengmeng <wu_mengmeng@foxmail.com>
 * Date: 2019/4/26 0026
 * Time: 14:35
 */

namespace HiCommon\Service;


use HiCommon\Repository\OrderCheckpointVehicleRepository;

class TaskQueryService extends BaseService
{
    /*定时任务查询*/


    /*查询数据-用户车辆年检预约到期提醒-提前15天*/
    public function njyy_query_user_vehicle_expire_remind(){

        //存放时间1天
        $n_time = 1*24*60*60;
        $now_day = date('Y-m-d');

        /*用户车辆年检提醒列表*/
        $result = OrderCheckpointVehicleRepository::waiting_for_remind_vehicle_list()->toarray();
        if(count($result) >= 1){
            $arr_data = $result;

            foreach ($arr_data as $value)
            {

                //只存放一次，期限为15天 同时只写入队列一次
                $key = 'str_njyy_remind_'.$value['order_sn'];
                $re = predis_str_get($key);
                if(is_null($re)){
                    predis_str_set($key,$value['order_sn'],$n_time);
                    $data = [
                      'order_sn'=>$value['order_sn'],
                      'remind_day'=>15
                    ];

                    $table = 'njyy_remind_'.$now_day;
                    queue_in($table,$data);
                }
            }

        }

    }

}